package dyyx.util;

import org.springframework.context.ApplicationContext;

import dyyx.HelloService;

public abstract class WebAppContextUtil {

	private static volatile ApplicationContext applicationContext;
	
	public synchronized static void setApplicationContext(ApplicationContext ctx){
		if(applicationContext!=null){
			return;
		}
		
		if(ctx!=null){
			applicationContext = ctx;
		}
	}
	
	
	public static ApplicationContext getApplicationContext(){
		return applicationContext;
	}
	
	
	public static HelloService getHelloService(){
		if(applicationContext==null){
			return null;
		} 
		return (HelloService)applicationContext.getBean("helloService");
	}


}
